XAPK Installer.apk(点击下载) / ProgressBarCircularIndeterminate.java


package com.gc.materialdesign.views;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
import c.d.a.d.a;
import c.d.a.e.b;
import kotlin.KotlinVersion;

public class ProgressBarCircularIndeterminate extends b {
    public int g = Color.parseColor("#1E88E5");
    public float h = 0.0f;
    public float i = 0.0f;
    public int j = 0;
    public boolean k = false;
    public int l = 1;
    public int m = 0;
    public float n = 0.0f;
    public int o = 0;

    public ProgressBarCircularIndeterminate(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        setAttributes(attributeSet);
    }

    public int a() {
        int i2 = this.g;
        return Color.argb(128, (i2 >> 16) & KotlinVersion.MAX_COMPONENT_VALUE, (i2 >> 8) & KotlinVersion.MAX_COMPONENT_VALUE, (i2 >> 0) & KotlinVersion.MAX_COMPONENT_VALUE);
    }

    public final void b(Canvas canvas) {
        if (this.m == this.o) {
            this.l += 6;
        }
        if (this.l >= 290 || this.m > this.o) {
            this.m += 6;
            this.l -= 6;
        }
        int i2 = this.m;
        if (i2 > this.o + 290) {
            this.o = i2;
            this.m = this.o;
            this.l = 1;
        }
        this.n += 4.0f;
        canvas.rotate(this.n, (float) (getWidth() / 2), (float) (getHeight() / 2));
        Bitmap createBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas2 = new Canvas(createBitmap);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(this.g);
        canvas2.drawArc(new RectF(0.0f, 0.0f, (float) getWidth(), (float) getHeight()), (float) this.m, (float) this.l, true, paint);
        Paint paint2 = new Paint();
        paint2.setAntiAlias(true);
        paint2.setColor(getResources().getColor(17170445));
        paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
        canvas2.drawCircle((float) (getWidth() / 2), (float) (getHeight() / 2), (float) ((getWidth() / 2) - a.a(4.0f, getResources())), paint2);
        canvas.drawBitmap(createBitmap, 0.0f, 0.0f, new Paint());
    }

    @Override // c.d.a.e.b
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (!this.k) {
            a(canvas);
        }
        if (this.j > 0) {
            b(canvas);
        }
        invalidate();
    }

    public void setAttributes(AttributeSet attributeSet) {
        setMinimumHeight(a.a(32.0f, getResources()));
        setMinimumWidth(a.a(32.0f, getResources()));
        int attributeResourceValue = attributeSet.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "background", -1);
        if (attributeResourceValue != -1) {
            setBackgroundColor(getResources().getColor(attributeResourceValue));
        } else {
            int attributeIntValue = attributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "background", -1);
            if (attributeIntValue != -1) {
                setBackgroundColor(attributeIntValue);
            } else {
                setBackgroundColor(Color.parseColor("#1E88E5"));
            }
        }
        setMinimumHeight(a.a(3.0f, getResources()));
    }

    public void setBackgroundColor(int i2) {
        super.setBackgroundColor(getResources().getColor(17170445));
        if (isEnabled()) {
            this.f1678e = this.g;
        }
        this.g = i2;
    }

    public final void a(Canvas canvas) {
        if (this.h < ((float) (getWidth() / 2))) {
            Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setColor(a());
            this.h = this.h >= ((float) (getWidth() / 2)) ? ((float) getWidth()) / 2.0f : this.h + 1.0f;
            canvas.drawCircle((float) (getWidth() / 2), (float) (getHeight() / 2), this.h, paint);
            return;
        }
        Bitmap createBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas2 = new Canvas(createBitmap);
        Paint paint2 = new Paint();
        paint2.setAntiAlias(true);
        paint2.setColor(a());
        canvas2.drawCircle((float) (getWidth() / 2), (float) (getHeight() / 2), (float) (getHeight() / 2), paint2);
        Paint paint3 = new Paint();
        paint3.setAntiAlias(true);
        paint3.setColor(getResources().getColor(17170445));
        paint3.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
        if (this.j >= 50) {
            this.i = this.i >= ((float) (getWidth() / 2)) ? ((float) getWidth()) / 2.0f : 1.0f + this.i;
        } else {
            this.i = this.i >= ((float) ((getWidth() / 2) - a.a(4.0f, getResources()))) ? (((float) getWidth()) / 2.0f) - ((float) a.a(4.0f, getResources())) : 1.0f + this.i;
        }
        canvas2.drawCircle((float) (getWidth() / 2), (float) (getHeight() / 2), this.i, paint3);
        canvas.drawBitmap(createBitmap, 0.0f, 0.0f, new Paint());
        if (this.i >= ((float) ((getWidth() / 2) - a.a(4.0f, getResources())))) {
            this.j++;
        }
        if (this.i >= ((float) (getWidth() / 2))) {
            this.k = true;
        }
    }
}